import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.1

Window {
    visible: true;
    width: 1200;
    height: 600;

    Rectangle {
        anchors.fill: parent;
        gradient: Gradient {
            GradientStop {
                position: 0.0;
                color: "lightskyblue";
            }
            GradientStop {
                position: 1.0;
                color: "skyblue";
            }
        }

        TextField {
            id: tf;
            //继承自FocusScope，FocusScope继承制Item，有width和height属性
            width: 400;
            height: 50;
            anchors.centerIn: parent;

            //设置font
            font.pixelSize: this.height * 0.6;
            font.family: "微软雅黑";

            style: TextFieldStyle {
                background: Rectangle {
                    anchors.fill: parent
                    color: "white";
                }
            }

            onAccepted: {
                //length获取text长度
                console.log("length: " + this.length);
                //text获取文本框内字符串
                console.log("text: " + this.text);
            }

            Component.onCompleted: {
                console.log(this.font.pixelSize);
            }
        }
    }
}
